home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / GMSMTH01.ZIP / PLAY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-28  |  2.8 KB  |  128 lines

  1. /*
  2.  
  3.     play.c
  4.  
  5.     Internet: alexad3@icebox.iceonline.com
  6.     Copyright 1994, September 26 by Alec Russell, ALL rights reserved
  7.  
  8.     Created - 1994/9/26
  9.    Part of the 3D ball demo
  10.  
  11.     History:
  12.         New file
  13.  
  14. */
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <conio.h>
  20. #include <alloc.h>
  21. #include <dos.h>
  22. #include <time.h>
  23.  
  24. #include <pr2.h>
  25. #include <mode13.h>
  26. #include <readlbm.h>
  27. #include <fstring.h>
  28. #include <g_io.h>
  29. #include <gui.h>
  30. #include <erase.h>
  31. #include <die.h>
  32. #include <gmalloc.h>
  33.  
  34. #include <Xlib_all.h>
  35. #include <tank-ii.h>
  36.  
  37.  
  38. /* ---------------------- play() --------------------- September 26,1994 */
  39. short play(void)
  40. {
  41.    short code=0;
  42.    int count;
  43.    unsigned long t1, t2;
  44.    BYTE far *dbuff;
  45.  
  46.    // for scaling
  47.    ClipLt=4;    // Left clipping boundry
  48.    ClipRt=283;  // Right clipping boundry
  49.    ClipTp=4;    // Top clipping boundry
  50.    ClipBt=162;  // Bottom clipping boundry
  51.  
  52.  
  53.    /* Clip rectangle; clips to the screen for polygons */
  54.    PolyClipMinX = 4;
  55.    PolyClipMinY = 4;
  56.    PolyClipMaxX = 284;
  57.    PolyClipMaxY = 163;
  58.  
  59.    PolyCentreX=(PolyClipMaxX - PolyClipMinX + 1) >>1;
  60.    PolyCentreY=(PolyClipMaxY - PolyClipMinY + 1) >>1;
  61.    PolyScreenWidth=INT_TO_FIXED(-ScrnLogicalPixelWidth);
  62.  
  63.    InitializeObjectList(); /* set up the initial objects */
  64.    InitializeFixedPoint(); /* set up fixed-point data */
  65.  
  66.    init_play_logic();
  67.  
  68.    init_play();
  69.    dbuff=gmalloc(280*160 + 8, "dark");
  70.    if ( !dbuff )
  71.       die("out of mem - dbuff");
  72.  
  73.    draw_back(HiddenPageOffs);
  74.    draw_back(VisiblePageOffs);
  75.    page=0;
  76.  
  77.    // to calc frame rate
  78.    count=100;
  79.    t1=fast_tick;
  80.  
  81.    while ( !pl.done )
  82.       {
  83.       /* erase old stuff */
  84.       draw_erase_rects(&(gb_h[page]));
  85.       //x_rect_fill(4,65, 284, 163, HiddenPageOffs, 13);  // dirt
  86.       x_put_pbm(4,65, HiddenPageOffs, play_data.grd_top);
  87.       //x_put_pbm(4,65, HiddenPageOffs, play_data.grd_top);
  88.       //x_put_pbm(4,100, HiddenPageOffs, play_data.grd_bot);
  89.  
  90.       draw_strip(4,4, 283, HiddenPageOffs, play_data.sky_pbm, (USHORT)pl.hd); // sky
  91.  
  92.       do_play_logic();
  93.  
  94.       do_play_draw();
  95.  
  96.       // a test only
  97.       //x_rect_or(54,20, (100/4), 80, HiddenPageOffs, dbuff, 128);
  98.       // x_rect_dark(56, 20, 25, 80, HiddenPageOffs);
  99.  
  100.       /* draw the mouse */
  101.       gui_draw_mouse();
  102.  
  103.       x_page_flip(0,0);
  104.       page= page ? 0 : 1;
  105.  
  106.       --count;
  107.       if ( count == 0 )
  108.          {
  109.          t2=fast_tick;
  110.          t2-=t1;
  111.          t2=7440 / t2;
  112.          pr2("%lu frames per second t1 %lu hd = %u", t2, t1, pl.hd);
  113.          count=100;
  114.          t1=fast_tick;
  115.          }
  116.       }
  117.  
  118.    gfree(dbuff, "dark");
  119.    deinit_play();
  120.  
  121.    pr2("about to exit play");
  122.    return(code);
  123. }
  124.  
  125.  
  126. /* ------------------------------ EOF -------------------------------- */
  127.  
  128.